package com.m3958.firstgwt.server.camel;

import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.http4.HttpMethods;

import com.google.inject.Inject;
import com.m3958.firstgwt.server.service.SiteConfigService;
import com.m3958.firstgwt.server.utils.Osdetecter;

public class SolrRouter extends RouteBuilder{
	
	@Inject
	private SiteConfigService scf;

	@Override
	public void configure() throws Exception {
    	String ff = "file://e:/solrcameldir";
    	String url = "http4://localhost:8080/solr/update";
    	if(!Osdetecter.isWindows()){
    		ff = "file:///usr/local/www/solrcameldir";
    		url = "http4://localhost:8983/solr/update";
    	}
    	from(ff).setHeader(Exchange.HTTP_QUERY, constant("commit=true")).
    		setHeader(Exchange.CONTENT_TYPE, constant("Conntent-Type: text/xml")).
    		setHeader(Exchange.HTTP_CHARACTER_ENCODING, constant("UTF-8")).
    		setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST)).to(url);
    	
    	from("file:///home/jianglibo/dic?include=words-my.dic").
    		to("file:///usr/local/apachesolr/apache-solr-3.2.0/example/solr/dic");
		
	}

}
